[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 TESTFILE

 Used to determine the extension of a filename and exit with an errorlevel.

 Syntax

 TESTFILE [filename] [ext] [ext] ... [ext]

 Command Line Parameters

 [filename]  The filename you want to check to determine the extension. If
             you are using TESTFILE in your PCBVIEW or PCBTEST batch
             files, specify %1 for the filename.

 [ext]       These parameters reference the filename extensions you want
             to check for.  If the filename you specify matches one of the
             extensions you enter as a parameter, PCBoard will exit with a
             unique errorlevel.  By testing the errorlevel returned, you
             can determine the extension of the filename.

 Description

 When you are passing a filename as a parameter to a batch file, quite often
 it is useful to know the extension of the file. Once you know the extension
 of the file, you can perform special processing.  For example you may want
 to treat files that end in .TXT different from those that end with .ZIP or
 .ARJ.

 To determine the extension of the file, you must specify the filename to
 test and the extension that you want to test on the command line when you
 execute TESTFILE.  The errorlevel that is returned will determine the
 extension of the file.

 Errorlevels Returned

 The errorlevel returned by TESTFILE is based on the placement of the
 extension on the command line.  The following example illustrates:

 TESTFILE FILENAME.TXT ZIP ARJ LHA TXT

 If you type this line at a DOS command prompt, TESTFILE will return an
 errorlevel of 4.  Why 4?  The reason that errorlevel 4 is returned is that
 it is the fourth extension specified on the command line.

 What if the extension of the file is not specified on the command line as
 shown in the following example?

 TESTFILE CONFIG.SYS ZIP ARJ LHA TXT

 In this situation, TESTFILE will return an errorlevel of 98. You will not
 know the file extension, but you will know that it is not one you included
 on the command line.

 Example

 Assuming you are using the following batch file named TESTIT.BAT

 @echo off
 testfile %1 zip arj gif
 if errorlevel==98 goto notknown
 if errorlevel==3 echo GIF file specified.
 if errorlevel==2 echo ARJ file specified.
 if errorlevel==1 echo ZIP file specified.
 goto end

 :notknown
 echo Could not determine extension.

 :end

 the following table will show the response for the value you pass as %1 to
 the batch file:

 %1 Parameter   Response From Batch File
 TEXTEDIT.ZIP   ZIP file specified.
 TEXTEDIT.EXE   Could not determine extension.
 WOODGRAN.ARJ   ARJ file specified.
 README.TXT     Could not determine extension.
 SCENE.GIF      GIF file specified.


This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson